﻿Imports System.ComponentModel 
Imports System.Collections  

Public Class CFondoIntermediario 
Implements INotifyPropertyChanged

   'Columnas sólo lectura
    'Fondos
    Private _codFondo              As String
    Private _salDisponible         As double   
    Private _ordenPend             As double
    Private _pendingCash           As double
    Private _pendingCashAjust      As double
    Private _saldoDecalogT         As double
    Private _saldoDecalogCalculado As Double  'Columana calculada


    'Columnas editadas 
    'Intermediarios    
    Private _intermediario1        As double     
    Private _intermediario2        As double
    Private _intermediario3        As double
    Private _intermediario4        As double
    Private _intermediario5        As double
    Private _intermediario6        As double
    Private _intermediario7        As double
    Private _intermediario8        As double
    Private _intermediario9        As double


    Private _fechaLiq              As String
    Private _fechaVtoReporto       As String
    


    Public const INDEXINICIOINTERMEDIARIO As Integer = 7
    Public const INDEXFININTERMEDIARIO As Integer = 15
  


    Public Event PropertyChanged As PropertyChangedEventHandler  Implements INotifyPropertyChanged.PropertyChanged 

   
    Public Shared Function  ObtenerPosiciones(ByVal nomPropiedad As String ) As Integer 
      
         Select Case nomPropiedad 

                Case "CodFondo"
                    Return 0
                Case "SalDisponible"
                    Return 1
                Case "OrdenPend"
                    Return 2
                Case "PendingCash"
                    Return 3
                Case "PendingCashAjust"
                    Return 4
                Case "SaldoDecalogT"
                    Return 5
                Case "SaldoDecalogCalculado"
                    Return 6
                Case "Intermediario1"
                    Return 7
                Case "Intermediario2"
                    Return 8
                Case "Intermediario3"
                    Return 9
                Case "Intermediario4"
                    Return 10
                Case "Intermediario5"
                    Return 11
                Case "Intermediario6"
                    Return 12
                Case "Intermediario7"
                    Return 13
                Case "Intermediario8"
                    Return 14
                Case "Intermediario9"
                    Return 15
                Case "FechaLiq"
                    Return 16
                Case "FechaVtoReporto"
                    Return 17
                Case ELSE
                    Return -1
             End Select
      
    End Function


    Public Shared Function ValorInicalColumna(ByVal index As Integer) As Object     
        
         Select Case index

                Case 0 'CodFondo
                     Return ""
                Case 1 'SalDisponible
                     Return 0
                Case 2 'OrdenPend
                     Return 0
                Case 3 'PendingCash
                     Return 0
                Case 4 'PendingCashAjust
                     Return 0
                Case 5 'SaldoDecalogT
                     Return 0                                   
                Case 6 'SaldoDecalogCalculado
                     Return 0                     
                Case 7 'Intermediario1
                     Return 0                      
                Case 8 'Intermediario2
                     Return 0                     
                Case 9 'Intermediario3
                     Return 0                      
                Case 10 'Intermediario4
                     Return 0                      
                Case 11 'Intermediario5
                     Return 0                      
                Case 12 'Intermediario6
                     Return 0                      
                Case 13 'Intermediario7
                     Return 0                      
                Case 14 'Intermediario8
                     Return 0                       
                Case 15 'Intermediario9
                     Return 0
                Case 16 'FechaLiq
                     Return ""
                Case 17 'FechaVtoReporto
                     Return ""                     
                Case Else 
                     Return Nothing            
            End Select


        
    End Function
    
    
    Private Sub NotificarCambio (propname As string  )
     RaiseEvent PropertyChanged(me, new PropertyChangedEventArgs(propname) )
    End Sub


    Default  Property  Columna(ByVal index As Integer) As Object
        Get    

                                                                                      
             Select Case index 

                Case 0
                    Return _codFondo
                Case 1
                    Return _salDisponible
                Case 2
                    Return _ordenPend
                Case 3
                    Return _pendingCash
                Case 4
                    Return _pendingCashAjust
                Case 5
                    Return _saldoDecalogT
                Case 6
                    Return _saldoDecalogCalculado
                Case 7
                    Return _intermediario1
                Case 8
                    Return _intermediario2
                Case 9
                    Return _intermediario3
                Case 10
                    Return _intermediario4
                Case 11
                    Return _intermediario5
                Case 12
                    Return _intermediario6
                Case 13
                    Return _intermediario7
                Case 14
                    Return _intermediario8
                Case 15
                    Return _intermediario9
                Case 16
                    Return _fechaLiq
                Case 17
                    Return _fechaVtoReporto
                Case ELSE
                    Return Nothing 
             End Select


        End Get
        Set(ByVal value As Object )
           
            Select Case index 

                Case 0
                    CodFondo  = value 
                Case 1
                     SalDisponible = value
                Case 2
                     OrdenPend = value
                Case 3
                     PendingCash = value
                Case 4
                     PendingCashAjust = value
                Case 5
                     SaldoDecalogT = value
                Case 6
                     _saldoDecalogCalculado = FormulaSalMenosInter ()
                Case 7
                       Intermediario1 = value                  
                Case 8
                     Intermediario2 = value
                Case 9
                     Intermediario3 = value
                Case 10
                     Intermediario4 = value
                Case 11
                     Intermediario5 = value
                Case 12
                     Intermediario6 = value
                Case 13
                     Intermediario7 = value
                Case 14
                     Intermediario8 = value
                Case 15
                     Intermediario9 = value
                Case 16
                     FechaLiq = value
                Case 17
                     FechaVtoReporto = value 

             End Select



        End Set

    End Property


    #Region "Bloque de solo lectura"

  


    Public Property CodFondo() As String
        Get 
            Return _codFondo
        End Get
        Set(ByVal value As String)
            _codFondo = value               
        End Set
    End Property


    Public Property SalDisponible() As double   
        Get
            Return _salDisponible
        End Get
        Set(ByVal value As double  )
            _salDisponible = value        
            NotificarCambio("SalDisponible")
        End Set
    End Property


    Public Property OrdenPend() As double
        Get
            Return _ordenPend 
        End Get
        Set(ByVal value As double )
            _ordenPend = value        
            NotificarCambio("OrdenPend")
        End Set
    End Property


    Public Property PendingCash() As double
        Get
            Return _pendingCash
        End Get
        Set(ByVal value As double )
            _pendingCash = value        
            NotificarCambio("PendingCash")
        End Set
    End Property


    Public Property PendingCashAjust() As double
        Get
            Return _pendingCashAjust
        End Get
        Set(ByVal value As double )
            _pendingCashAjust = value        
            NotificarCambio("PendingCashAjust")
        End Set
    End Property


    Public Property SaldoDecalogT() As double
        Get
            Return _saldoDecalogT
        End Get
        Set(ByVal value As double )
            _saldoDecalogT = value
            NotificarCambio("SaldoDecalogT")
        End Set

    End Property


    Public ReadOnly  Property SaldoDecalogCalculado() As double
        Get
            Return _saldoDecalogCalculado
        End Get
        
    End Property


  





    #End Region


    #Region "Bloque capturable"

 

    Public Property Intermediario1() As Double 
        Get
            Return _intermediario1 
        End Get
        Set(ByVal value As Double)
            
               If   value > 0 then 
                   _intermediario1 = value                                              
                Else
                   _intermediario1 = 0                                                                              
               End If                         

               NotificarCambio("Intermediario1")    
    
             _saldoDecalogCalculado = FormulaSalMenosInter()
              NotificarCambio ("SaldoDecalogCalculado") 
        End Set


    End Property


    Public Property Intermediario2() As Double 
        Get
            Return _intermediario2
        End Get
        
        Set(ByVal value As Double)
        
           If value > 0 then 
              _intermediario2 = value                               
           Else                               
              _intermediario2 = 0                                    
           End If                         

           NotificarCambio("Intermediario2")                   

         _saldoDecalogCalculado = FormulaSalMenosInter()
         NotificarCambio ("SaldoDecalogCalculado") 


        End Set
    End Property


    Public Property Intermediario3() As Double 
        Get
            Return _intermediario3 
        End Get
        Set(ByVal value As Double)

          If  value > 0 then 
              _intermediario3 = value                                              
          Else
              _intermediario3 = 0                                                                              
          End If              

          NotificarCambio("Intermediario3")       


        _saldoDecalogCalculado = FormulaSalMenosInter()
        NotificarCambio ("SaldoDecalogCalculado") 


        End Set
    End Property



    Public Property Intermediario4() As Double
        Get
            Return _intermediario4
        End Get
        Set(ByVal value As Double)

        If  value > 0 then 
              _intermediario4 = value                                              
        Else
              _intermediario4 = 0                                                                              
        End If              

        NotificarCambio("Intermediario4")       

        _saldoDecalogCalculado = FormulaSalMenosInter()
        NotificarCambio ("SaldoDecalogCalculado") 


        End Set
    End Property


    Public Property Intermediario5() As Double
        Get
            Return _intermediario5
        End Get
        Set(ByVal value As Double)
   
        If  value > 0 then 
              _intermediario5 = value                                              
        Else
              _intermediario5 = 0                                                                              
        End If              

        NotificarCambio("Intermediario5")       

        _saldoDecalogCalculado = FormulaSalMenosInter()
        NotificarCambio ("SaldoDecalogCalculado") 


        End Set
    End Property


    Public Property Intermediario6() As Double
        Get
            Return _intermediario6
        End Get
        Set(ByVal value As Double)
   
        If  value > 0 then 
              _intermediario6 = value                                              
        Else
              _intermediario6 = 0                                                                              
        End If              

        NotificarCambio("Intermediario6")       
    

        _saldoDecalogCalculado = FormulaSalMenosInter()
        NotificarCambio ("SaldoDecalogCalculado") 

        End Set
    End Property


    Public Property Intermediario7() As Double
        Get
            Return _intermediario7
        End Get
        Set(ByVal value As Double)
  
        If  value > 0 then 
              _intermediario7 = value                                              
        Else
              _intermediario7 = 0                                                                              
        End If              

        NotificarCambio("Intermediario7")       

            _saldoDecalogCalculado = FormulaSalMenosInter()
            NotificarCambio ("SaldoDecalogCalculado") 

        End Set
    End Property


    Public Property Intermediario8() As Double
        Get
            Return _intermediario8 
        End Get
        Set(ByVal value As Double)

        If  value > 0 then 
              _intermediario8 = value                                              
        Else
              _intermediario8 = 0                                                                              
        End If              

        NotificarCambio("Intermediario8")       
    
            _saldoDecalogCalculado = FormulaSalMenosInter()
            NotificarCambio ("SaldoDecalogCalculado") 


        End Set
    End Property


    Public Property Intermediario9() As Double
        Get
            Return _intermediario9
        End Get
        Set(ByVal value As Double)
    
        If  value > 0 then 
              _intermediario9 = value                                              
        Else
              _intermediario9 = 0                                                                              
        End If              

        NotificarCambio("Intermediario9")       

        _saldoDecalogCalculado = FormulaSalMenosInter()
        NotificarCambio ("SaldoDecalogCalculado") 

        End Set
    End Property


    Public Property FechaLiq() As String
        Get
            Return _fechaLiq
        End Get
        Set(ByVal value As String)
        If IsDate (value) then 
           _fechaLiq = value       
        End If

        
        End Set
    End Property


    Public Property FechaVtoReporto() As String 
        Get
            Return _fechaVtoReporto 
        End Get
        Set(ByVal value As String )
          If IsDate (value) then 
             _fechaVtoReporto = value        
          End If
        
        End Set
    End Property


    #End Region



    Public Sub New(ByVal codFondo As String, ByVal salDisponible As double, ByVal ordenPend As double,  _
                   ByVal pendingCash As double,  ByVal PendingCashAjust As double, ByVal  saldoDecalogT  As double, ByVal fechaHoy As String, ByVal fechasig As String)




    'Fondos 

    _codFondo         = codFondo
    _salDisponible    = salDisponible 
    _ordenPend        = ordenPend
    _pendingCash      = pendingCash
    _PendingCashAjust = PendingCashAjust
    _saldoDecalogT    = saldoDecalogT


    'Intermediarios

    _intermediario1   = 0
    _intermediario2   = 0
    _intermediario3   = 0
    _intermediario4   = 0
    _intermediario5   = 0
    _intermediario6   = 0
    _intermediario7   = 0
    _intermediario8   = 0
    _intermediario9   = 0
    _fechaLiq         = fechaHoy 
    _fechaVtoReporto  = fechasig 



    'Campo calculado

    _saldoDecalogCalculado = FormulaSalMenosInter()



    End Sub


    Private Function  FormulaSalMenosInter() As Double 
  
 
      Return _saldoDecalogT  -   (  _intermediario1 + _
                                    _intermediario2 + _
                                    _intermediario3 + _
                                    _intermediario4 + _
                                    _intermediario5 + _
                                    _intermediario6 + _
                                    _intermediario7 + _
                                    _intermediario8 + _
                                    _intermediario9 
                                  )
                                                                                               
                                                 
    End Function  




    
End Class
